package api.cie.rss.dal;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

/**
 * The class to open or close the database
 * @author STL-API
 *
 */
public class DatabaseAdapter {

	private Context context;
	private SQLiteDatabase database;
	private RssReaderDatabaseHelper dbHelper;
	
	public SQLiteDatabase getDatabase() {
		return database;
	}
	
	public DatabaseAdapter(Context context) {
		this.context = context;
	}
	
	public DatabaseAdapter open() throws SQLException {
		dbHelper = new RssReaderDatabaseHelper(context);
		database = dbHelper.getWritableDatabase();
		return this;
	}
	
	public void close() {
		dbHelper.close();
	}
	
}
